// import store from '@/store'
import { getRouterItem } from '@/utils/storage'
export default {
  inserted (el, binding, vnode) {
    const { value } = binding
    // const router_id = store.getters && store.getters.router_id;
    const router_id = getRouterItem()

    if (value && typeof value === 'string' && value.length > 0) {
      const permissionRoles = value
      const hasPermission = router_id.some(id => permissionRoles === id)
      if (!hasPermission) {
        el.parentNode && el.parentNode.removeChild(el)
      }
    } else {
      throw new Error('need viewId! Like v-permission="editorBtn"')
    }
  }
}
